package com.blog.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.blog.entity.ArticleLike;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface ArticleLikeMapper extends BaseMapper<ArticleLike> {
    
    /**
     * 查询文章点赞数
     */
    @Select("SELECT COUNT(*) FROM article_like WHERE article_id = #{articleId}")
    Integer selectLikeCount(Long articleId);
    
    /**
     * 查询用户是否已点赞
     */
    @Select("SELECT COUNT(*) FROM article_like WHERE article_id = #{articleId} AND user_id = #{userId}")
    Integer isLiked(Long articleId, Long userId);
} 